package com.msmall.community.common.action.html;

import java.util.List;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantAjax;
import com.msmall.community.common.model.City;
import com.msmall.community.common.service.CityManager;

public class CityAction extends HTMLBaseAction{

	private static final long serialVersionUID = -5969524795702456650L;

	private String code;
	
	private CityManager cityManager;

	public String getChildren(){
		StringBuffer buf = new StringBuffer();
		try {
			List<City> children = cityManager.getChildCities(code);
			buf.append(ConstantAjax.CONTENT_PRE);
			for(int i=0; i<children.size(); i++){
				City city = children.get(i);
				buf.append(ConstantAjax.ITEM_PRE)
				.append(createPosition(city.getCityCode()))
				.append(createValue(city.getFullName()))
				.append(ConstantAjax.ITEM_SUFF);
			}
			buf.append(ConstantAjax.CONTENT_SUFF);
		} catch (Exception e) {
		}
		message = buf.toString();
		return SUCCESS;
	}
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setCityManager(CityManager cityManager) {
		this.cityManager = cityManager;
	}

}
